#include "gtest/gtest.h"
//TODO:  interface design 
//1. default operations 
//2. range query: (pattern)
//3. column family(pattern)
//  3.1 iterator,
//  3.2 foreach
//4. prefix table 
//5. options:  (pattern)
//      Options: public DBOptions, ColumnFamilyOptions; 
//      ReadOptions; 
//      WriteOptions
//6. customer Comparator 
//7. batch interface 
//8. Merge interface 
//
//




/*
TEST(NewRocksdbTest, test){
    auto && [ok, db] = Rocksdb::open("dir.db", Options); //unique_ptr
    ASSERT_TRUE(ok);


    ITable * tab = db->getDefaut();;
    tab->put(k, v, WriteOptions);
    tab->get(k, v, ReadOptions);
    tab->del(k, WriteOptions);
    tab->close(); // optional 

    {
        auto && iter = tab->range(); //unique_ptr
        fo(; iter->hasNext(); iter->next()){
            iter->current();
        }
        auto && iter = tab->range(start); //unique_ptr
        //...
        auto && iter = tab->range(start, end); //unique_ptr
        //...
    }


    {

        ColumnFamilyDB * dbcf = ColumnFamilyDB(db->instance());
        ITable & tabcf = dbcf->create("cfname", CfOptions & );
        bool = dbcf->contains("cfname");
        {
            ITable & tabcf = tables.get("namecf");
            tabcf.put();
            tabcf.get();
            tabcf.del();
            tabcf.range();
            tabcf.close();
        }

        auto && [ok, cf] = ColumnFamily::open("market", db, cfOptions); // unique_ptr
        auto && [ok, cf] = ColumnFamily::openOrCreate("market", db, cfOptions); // unique_ptr
        cf->put(k, v, WriteOptions); 
        cf->get(k, v, ReadOptions);
        cf->del(k, WriteOptions);
        cf->close(); //optional 

        {
            auto iter = ColumnFamilyIterator::New(db); //unique_ptr
            for(iter; it->hasNext(); iter->next()){
                auto &&(key, value) = it->current();
            }
        }
    }


    {
        auto &&  [table, exist] = db.getTable(tabName);
        ASSERT_TRUE(exist);
        table.put("key", "value");
        table.close(); //flush data
    }

    db.dropTable(tabName);

    db.close();
}*/


/*  
TEST(OptionalRocksdb, testMain){

  auto*  rdb = new Rocksdb(path, optArgs); 
  auto * optdb = new OptionalRocksdb(rdb, new_read, new_write, new_option);
  optdb->open();//rdb must not opened

  optdb->put(ReadOption(), "key", "value");

  optdb->close();
  delete optdb;
  delete  rdb;
}*/

/*  
TEST(ColumnFamilyRocksdbTest, testMain){
  auto * rdb = new Rocksdb(path, optArgs);
  ColumnFamilyRocksdb cfdb(rdb);

  cfdb.open(); //load the columnfamily exist in disk

  const char * tabname = "tabName";
  ASSERT_FALSE(dfdb.tables().contains(tabname);

  ITable & table = dfdb.tables().create(tabname, read, write, columnfamily);

  table.put("key", "value");
  table.del("key");

  std::string value;
  table.get("key", value);

  tables().drop(table.name());
}

TEST(NamespaceRocksdbTest, testMain){
  Rocksdb rdb(path, optArgs);
  NamespaceRocksdb nsdb(rdb);
  const char * tabname = "tab_prefix";
  ASSERT_FALSE(dfdb.tables().contains(tabname));
  
  ITable & table = dfdb.tables().create(tabname, read, write, columnfamily);
  table.put("key", "value"); 
  table.del("key")

  std::string value;
  table.get("key", value);

  dfdb.tables().drop(table.name());
}*/
